//
//  HPHomeViewModel.swift
//  TLenPoint
//
//  Created by Docker on 2018/3/23.
//  Copyright © 2018年 Docker. All rights reserved.
//

import UIKit
import ReactiveSwift
class HPHomeViewModel: NSObject {

    var rotato:[RotatoModel] = [RotatoModel]()
    var simulationList:[HPSimulationListModel] = [HPSimulationListModel]()
    func RestData(callBack:@escaping (Bool, String)->()){
         let dict = ["positions":"1"]
        LPBaseNetWorking().Hp_WithRequestType(requestType: .Post, urlString: BaseUrl, params: dict, actionName: "QueryAdvertisment") { (result, error) in
            
            let dic = result as! [String:Any]
            let result = dic["resultCode"] as! NSInteger
            if(result == 0){
                print(dic)
                let dict = dic["advertismentList"] as! [[String:Any]]
                let array = NSArray.yy_modelArray(with: RotatoModel.self, json: dict) as! [RotatoModel]
                self.rotato = array
                callBack(true, "数据加载成功")
            }
            
        }

    }

    func RestHomeGameData(feeType:String,callBack:@escaping (Bool, String)->()){
        let dict = ["position":"1",
                    "feeType":feeType,
                    "version":"1"]
        LPBaseNetWorking().Hp_WithRequestType(requestType: .Post, urlString: BaseUrl, params: dict, actionName: "QueryAwordContestList") { (result, error) in
            let dic = result as! [String:Any]
            let result = dic["resultCode"] as! NSInteger
            if(result == 0){
                print(dic)
                let dict = dic["awordContest"] as! [[String:Any]]
                let array = NSArray.yy_modelArray(with: HPSimulationListModel.self, json: dict) as! [HPSimulationListModel]
                self.simulationList = array
                callBack(true, "数据加载成功")
            }
            
        }
        
    }
    
}
